using Bean.Entity.Enum;
using Newtonsoft.Json;
using SqlSugar;

namespace Bean.Entity.Model;

/// <summary>
/// 对应的展位信息
/// </summary>
public class Exhibit
{
    /// <summary>
    /// 展位id
    /// </summary>
    public long exhibitid { get; set; }

    /// <summary>
    /// 展位名称
    /// </summary>
    public string exhibitname { get; set; }

    /// <summary>
    /// 展位类型：0标准，1非标
    /// </summary>
    public ProductTypeEnum exhibitType { get; set; }

    /// <summary>
    /// 展位类型描述
    /// </summary>
    // public string exhibitTypeDesc => exhibitType.GetDescription();

    /// <summary>
    /// 采购商ID
    /// </summary>
    public long SID { get; set; }

    /// <summary>
    /// 采购商名称
    /// </summary>
    // public string SIDName { get; set; }

    /// <summary>
    /// 服务商编码
    /// </summary>
    // public string SPCode { get; set; }

    /// <summary>
    /// OTA平台ID
    /// </summary>
    public int cid { get; set; }


    /// <summary>
    /// 展位描述
    /// </summary>
    public string ExhibitDesc { get; set; }

    /// <summary>
    /// 展位配置信息
    /// </summary>
    [SugarColumn(IsIgnore = true)]
    public string exhibitconfigText { get; set; }

    /// <summary>
    /// 展位编码
    /// </summary>
    public string exhibitcode { get; set; }


    /// <summary>
    /// 状态，0-禁用/1-启用
    /// </summary>
    public int status { get; set; }

    /// <summary>
    /// 是否支持二次出票：1支持
    /// </summary>
    public int IsSecondaryTicket { get; set; }
    
    /// <summary>
    /// 
    /// </summary>
    [SugarColumn(IsIgnore = true)]
    public string IsSecondaryTicketDesc => IsSecondaryTicket == 1 ? "支持" : "不支持";

    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime createtime { get; set; }

    /// <summary>
    /// 修改时间
    /// </summary>
    public DateTime updatetime { get; set; }

    /// <summary>
    /// 创建人
    /// </summary>
    public long createuser { get; set; }

    /// <summary>
    /// 修改人
    /// </summary>
    public long updateuser { get; set; }

    /// <summary>
    /// 子产品
    /// </summary>
    // public string ChildrenProduct { get; set; }

    /// <summary>
    /// 
    /// </summary>
    // public List<string> ChildrenProductDesc =>
    //     string.IsNullOrEmpty(ChildrenProduct) ? [] : [..ChildrenProduct.Split('\n')];


    /// <summary>
    /// 展位配置信息
    /// </summary>
    [SugarColumn(IsIgnore = true)]
    public exhibitconfig? exhibitconfigInfo
    {
        get
        {
            try
            {
                return !string.IsNullOrWhiteSpace(exhibitconfigText) ? JsonConvert.DeserializeObject<exhibitconfig>(exhibitconfigText) : new exhibitconfig();
            }
            catch (Exception ex)
            {
                return new exhibitconfig();
            }
        }
    }
    
    /// <summary>
    /// mark值
    /// </summary>
    [SugarColumn(IsIgnore = true)]
    public string mark => exhibitconfigInfo.mark;
    
    /// <summary>
    /// 出票时限
    /// </summary>
    [SugarColumn(IsIgnore = true)]
    public string tickettime => exhibitconfigInfo.tickettime;
    
    /// <summary>
    /// 服务商名称
    /// </summary>
    [SugarColumn(IsIgnore = true)]
    public string serviceprovidername { get; set; }
}

/// <summary>
/// 展位配置信息
/// </summary>
public class exhibitconfig
{
    /// <summary>
    /// mark值
    /// </summary>
    public string mark { get; set; }

    /// <summary>
    /// 出票时限
    /// </summary>
    public string tickettime { get; set; }
}